#ifndef UIFUNDLIST_H
#define UIFUNDLIST_H

#include "sql_fundlist.h"

//#include "queueList.h"
#include <QWidget>
#include <QtWidgets/QListWidget>
#include "funddata.h"

namespace Ui {
class UIFundList;
}

class UIFundList : public QWidget
{
    Q_OBJECT

public:
    explicit UIFundList(QWidget *parent = nullptr);
    ~UIFundList();

    int size();
    QString getCode(int index);
    QString getName(int index);

//    void updateUIList();
private:
    typedef struct __queueFundListData_t queueFundListData_t;
    Ui::UIFundList *ui;
    SQL_FundList *sqlList;
//    FundData *fundData;
    QList<queueFundListData_t> *fundDataList = NULL;
    QListWidgetItem *taiLineItem;

    void initAllItem();
    void initTailLine();
    bool addNewLine(QString code, QString name);

    void deleteLine(QString code);
    void deleteTailLine();
    void deleteAllItem();

//    void updateQueueListFromSQL();

//    void addSingleHorizonItem(QString code, QString name);
    void relocate();
    void resize();

private slots:
    void buttonDeleteSingleItem();
    void buttonAddSingleItem();

signals:
    void deleteFund(QString);
    void addFund(QString, QString);

private slots:
    void gottenSingleData(QString code, bool rslt);

protected:
    virtual void resizeEvent(QResizeEvent *event) override;
};

#endif // UIFUNDLIST_H
